; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --include-generated-funcs
; RUN: llc -enable-machine-outliner -mtriple=lanai-unknown-linux < %s | FileCheck %s

; NOTE: Machine outliner doesn't run.
@x = global i32 0, align 4

define dso_local i32 @check_boundaries() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 0, i32* %1, align 4
  store i32 0, i32* %2, align 4
  %6 = load i32, i32* %2, align 4
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %9, label %8

  store i32 1, i32* %2, align 4
  store i32 2, i32* %3, align 4
  store i32 3, i32* %4, align 4
  store i32 4, i32* %5, align 4
  br label %10

  store i32 1, i32* %4, align 4
  br label %10

  %11 = load i32, i32* %2, align 4
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %14, label %13

  store i32 1, i32* %2, align 4
  store i32 2, i32* %3, align 4
  store i32 3, i32* %4, align 4
  store i32 4, i32* %5, align 4
  br label %15

  store i32 1, i32* %4, align 4
  br label %15

  ret i32 0
}

define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4

  store i32 0, i32* %1, align 4
  store i32 0, i32* @x, align 4
  store i32 1, i32* %2, align 4
  store i32 2, i32* %3, align 4
  store i32 3, i32* %4, align 4
  store i32 4, i32* %5, align 4
  store i32 1, i32* @x, align 4
  call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"()
  store i32 1, i32* %2, align 4
  store i32 2, i32* %3, align 4
  store i32 3, i32* %4, align 4
  store i32 4, i32* %5, align 4
  ret i32 0
}

attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="all" }
; CHECK-LABEL: check_boundaries:
; CHECK:       .Lcheck_boundaries$local:
; CHECK-NEXT:    .type .Lcheck_boundaries$local,@function
; CHECK-NEXT:    .cfi_startproc
; CHECK-NEXT:  ! %bb.0:
; CHECK-NEXT:    st %fp, [--%sp]
; CHECK-NEXT:    add %sp, 0x8, %fp
; CHECK-NEXT:    sub %sp, 0x20, %sp
; CHECK-NEXT:    st %r0, -12[%fp]
; CHECK-NEXT:    sub.f %r0, 0x0, %r0
; CHECK-NEXT:    st %r0, -16[%fp]
; CHECK-NEXT:    beq .LBB0_1
; CHECK-NEXT:    mov 0x1, %r3
; CHECK-NEXT:  .LBB0_2:
; CHECK-NEXT:    bt .LBB0_3
; CHECK-NEXT:    st %r3, -24[%fp]
; CHECK-NEXT:  .LBB0_1:
; CHECK-NEXT:    st %r3, -16[%fp]
; CHECK-NEXT:    mov 0x2, %r3
; CHECK-NEXT:    st %r3, -20[%fp]
; CHECK-NEXT:    mov 0x3, %r3
; CHECK-NEXT:    st %r3, -24[%fp]
; CHECK-NEXT:    mov 0x4, %r3
; CHECK-NEXT:    st %r3, -28[%fp]
; CHECK-NEXT:  .LBB0_3:
; CHECK-NEXT:    ld -16[%fp], %r3
; CHECK-NEXT:    sub.f %r3, 0x0, %r0
; CHECK-NEXT:    beq .LBB0_4
; CHECK-NEXT:    nop
; CHECK-NEXT:  .LBB0_5:
; CHECK-NEXT:    mov 0x1, %r3
; CHECK-NEXT:    bt .LBB0_6
; CHECK-NEXT:    st %r3, -24[%fp]
; CHECK-NEXT:  .LBB0_4:
; CHECK-NEXT:    mov 0x1, %r3
; CHECK-NEXT:    st %r3, -16[%fp]
; CHECK-NEXT:    mov 0x2, %r3
; CHECK-NEXT:    st %r3, -20[%fp]
; CHECK-NEXT:    mov 0x3, %r3
; CHECK-NEXT:    st %r3, -24[%fp]
; CHECK-NEXT:    mov 0x4, %r3
; CHECK-NEXT:    st %r3, -28[%fp]
; CHECK-NEXT:  .LBB0_6:
; CHECK-NEXT:    or %r0, 0x0, %rv
; CHECK-NEXT:    ld -4[%fp], %pc ! return
; CHECK-NEXT:    add %fp, 0x0, %sp
; CHECK-NEXT:    ld -8[%fp], %fp
;
; CHECK-LABEL: main:
; CHECK:       .Lmain$local:
; CHECK-NEXT:    .type .Lmain$local,@function
; CHECK-NEXT:    .cfi_startproc
; CHECK-NEXT:  ! %bb.0:
; CHECK-NEXT:    st %fp, [--%sp]
; CHECK-NEXT:    add %sp, 0x8, %fp
; CHECK-NEXT:    sub %sp, 0x20, %sp
; CHECK-NEXT:    st %r0, -12[%fp]
; CHECK-NEXT:    mov hi(x), %r3
; CHECK-NEXT:    or %r3, lo(x), %r3
; CHECK-NEXT:    mov 0x1, %r9
; CHECK-NEXT:    st %r9, -16[%fp]
; CHECK-NEXT:    mov 0x2, %r12
; CHECK-NEXT:    st %r12, -20[%fp]
; CHECK-NEXT:    mov 0x3, %r13
; CHECK-NEXT:    st %r13, -24[%fp]
; CHECK-NEXT:    mov 0x4, %r14
; CHECK-NEXT:    st %r14, -28[%fp]
; CHECK-NEXT:    st %r9, 0[%r3]
; CHECK-NEXT:    !APP
; CHECK-NEXT:    !NO_APP
; CHECK-NEXT:    st %r9, -16[%fp]
; CHECK-NEXT:    st %r12, -20[%fp]
; CHECK-NEXT:    st %r13, -24[%fp]
; CHECK-NEXT:    st %r14, -28[%fp]
; CHECK-NEXT:    or %r0, 0x0, %rv
; CHECK-NEXT:    ld -4[%fp], %pc ! return
; CHECK-NEXT:    add %fp, 0x0, %sp
; CHECK-NEXT:    ld -8[%fp], %fp
